package cn.lixu.openfeign;

import cn.lixu.domain.Users;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @ProjectName: springcloud-alibaba-parent-homework
 * @Package: cn.lixu.openfeign
 * @ClassName: OpenFeignDownGrade
 * @Author: LIXU
 * @Description: OpenFeign整合Sentinel熔断, 在openfeign接口上加上
 * @Date: 2022/08/25 0025 0:58:57
 * @Version: 1.0
 **/
@Component
public class OpenFeignDownGrade implements FallbackFactory<UserOpenFeign> {

    @Override
    public UserOpenFeign create(Throwable throwable) {
        return new UserOpenFeign() {
            @Override
            public Users getById(Long id) {
                return new Users(-1L, "罗顶天，你被熔断了", "你是不是不服气");
            }
        };
    }
}
